const app = getApp();
Page({
  data: {
    money: '55',
    orderNum: ''
  },
  onLoad: function (options) {
    this.setData({
      money: options.money,
      orderNum: options.orderNum
    })
    console.log(options)
  },
  pay() {
    app.payOrder({ order_sn: this.data.orderNum }, (data) => {
      console.log(data)
      wx.requestPayment({
        'appId': data.appId,
        'timeStamp': data.timeStamp,
        'nonceStr': data.nonceStr,
        'package': data.package,
        'signType': data.signType,
        'paySign': data.paySign,
        'success': function (res) {
          console.log('paySuccess', res)
          console.log('buyOrderType', app.Store.get('buyOrderType'))
          setTimeout(() => {
            if (app.Store.get('buyOrderType') === 'init') {
              app.WxService.reLaunch(`/pages/order/index/index`, { type: 'init' })
            } else {
              app.WxService.reLaunch(`/pages/order/index/index`, { type: 'supply' })
            }
          }, 100)

        },
        'fail': function (res) {
          console.log(res)
        },
        'complete': function (res) {
          // console.log(res)
        }
      })
    })
  }
})